package com.x.erp.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.alibaba.dubbo.config.annotation.Service;
import com.x.erp.dao.ApkDao;
import com.x.erp.model.Apk;
import com.x.erp.rpc.ApkRpcService;
import com.x.framework.exception.BusinessException;
import com.x.framework.exception.ExceptionCode;
import com.x.framework.service.BaseService;

/**
 * app安装包版本服务
 */
@Component
@Service(interfaceName = "com.x.erp.rpc.ApkRpcService", timeout = 60000)
public class ApkService extends BaseService implements ApkRpcService {

	@Autowired
	private ApkDao apkDao;//app安装包版本信息DAO

	/**
	 * 查询app安装包版本列表
	 * @param apk
	 * @return
	 */
	@Override
	public List<Apk> selectApkList(Apk apk){
		try {
			return apkDao.selectApkList(apk);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 查询app安装包版本数量
	 * @param apk
	 * @return
	 */
	@Override
	public int selectApkNum(Apk apk){
		try {
			return apkDao.selectApkNum(apk);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 新增app安装包版本信息
	 * @param apk
	 * @return
	 */
	@Override
	public Apk insertApk(Apk apk){
		try {
			return this.insert(apk);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 修改app安装包版本信息
	 * @param apk
	 * @return
	 */
	@Override
	public int updateApk(Apk apk){
		try {
			return this.update(apk);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

}
